/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.admin.entity;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.modules.admin.vo.plan.PlanUserSignDetailVo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 维保任务关联人员中间表实体类
 *
 * @author BladeX
 * @since 2021-05-10
 */
@Data
@TableName("blade_maintain_plan_content_user")
@ApiModel(value = "MaintainPlanContentUser对象", description = "维保任务关联人员中间表")
public class MaintainPlanContentUser extends TenantEntity implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 计划任务id
	 */
	@ApiModelProperty(value = "计划任务id")
	private Long planId;
	/**
	 * 用户id
	 */
	@ApiModelProperty(value = "用户id")
	private Long userId;

	@ApiModelProperty(value = "用户签到信息")
	private String signInfo;

	@TableField(exist = false)
	private String userName;

	@TableField(exist = false)
	private PlanUserSignDetailVo signUser;

	@TableField(exist = false)
	private Integer userSignCount;

	@ApiModelProperty("维修预警状态:维修消息通知状态1:准时达，2:超时达，3:超时未达4：即将超时达4：未及时出发")
	private Integer wxArriveStatus;

	@ApiModelProperty(value = "维修预计达到时间")
	private Date planArriveDate;

	@ApiModelProperty(value = "维修实际计划时间")
	private Date realityPlanDate;


	public void setSignInfo(String signInfo) {
		if (StrUtil.isNotEmpty(signInfo)) {
			signUser = new PlanUserSignDetailVo();
			String[] split = signInfo.split("%");
			for (String str : split) {
				PlanUserSignDetailVo planUserSignDetailVo = JSON.parseObject(str, PlanUserSignDetailVo.class);
				signUser = planUserSignDetailVo;
			}
		}
		this.signInfo = signInfo;
	}



	@ApiModelProperty(value = "用户签到信息")
	private String signStatusInfo;

	@TableField(exist = false)
	private String deptIds;

	@TableField(exist = false)
	private List<String> deptNames;

	@TableField(exist = false)
	private List<String> roleNames;

	@TableField(exist = false)
	private String roleIds;

	/**
	 * 工作时长 分钟（工单每日每人总时长）
	 */
	@TableField(exist = false)
	private BigDecimal workTime;

	/**
	 * 签到正常次数
	 */
	@TableField(exist = false)
	private Integer signNormal;

	/**
	 * 签退正常次数 （包含系统代签）
	 */
	@TableField(exist = false)
	private Integer signOutNormal;

	/**
	 * 签到异常次数
	 */
	@TableField(exist = false)
	private Integer signError;

	/**
	 * 签退异常次数
	 */
	@TableField(exist = false)
	private Integer signOutError;

	/**
	 * 系统代签次数
	 */
	@TableField(exist = false)
	private Integer signSystem;

	/**
	 * 开始时间
	 */
	@TableField(exist = false)
	private Date planBeginTime;

	/**
	 * 结束时间
	 */
	@TableField(exist = false)
	private Date planEndTime;

	/**
	 * 计划时间
	 */
	@TableField(exist = false)
	private Date planDate;

	/**
	 * 电梯id
	 */
	@TableField(exist = false)
	private Long elevatorId;

	/**
	 * 工单类型
	 */
	@TableField(exist = false)
	private Integer typeStatus;

	/**
	 * 工单类型
	 */
	@TableField(exist = false)
	private Integer planStatus;

	@ApiModelProperty("工单来源1:转进2:转出")
	private Integer createFrom;

	@ApiModelProperty("距离单位米:分配工单时距离项目的直线距离")
	private Integer distance;
}
